cairo_surface_destroy (surface);
}
-/**
- * gdk_cairo_set_source_window:
- * @cr: a cairo context
- * @window: a #GdkWindow
- * @x: X coordinate of location to place upper left corner of @window
- * @y: Y coordinate of location to place upper left corner of @window
- *
- * Sets the given window as the source pattern for @cr.
- *
- * The pattern has an extend mode of %CAIRO_EXTEND_NONE and is aligned
- * so that the origin of @window is @x, @y. The window contains all its
- * subwindows when rendering.
- *
- * Note that the contents of @window are undefined outside of the
- * visible part of @window, so use this function with care.
- *
- * Since: 2.24
- */
-void
-gdk_cairo_set_source_window (cairo_t *cr,
- GdkWindow *window,
- gdouble x,
- gdouble y)
-{
- cairo_surface_t *surface;
-
- g_return_if_fail (cr != NULL);
- g_return_if_fail (GDK_IS_WINDOW (window));
-
- surface = _gdk_window_ref_cairo_surface (window);
- cairo_set_source_surface (cr, surface, x, y);
- cairo_surface_destroy (surface);
-}
-
/*
* _gdk_cairo_surface_extents:
* @surface: surface to measure
* #GdkWindows and cairo surfaces.
*/
-
-/**
- * gdk_pixbuf_get_from_window:
- * @window: Source window
- * @src_x: Source X coordinate within @window
- * @src_y: Source Y coordinate within @window
- * @width: Width in pixels of region to get
- * @height: Height in pixels of region to get
- *
- * Transfers image data from a #GdkWindow and converts it to an RGB(A)
- * representation inside a #GdkPixbuf. In other words, copies
- * image data from a server-side drawable to a client-side RGB(A) buffer.
- * This allows you to efficiently read individual pixels on the client side.
- *
- * This function will create an RGB pixbuf with 8 bits per channel with
- * the size specified by the @width and @height arguments scaled by the
- * scale factor of @window. The pixbuf will contain an alpha channel if
- * the @window contains one.
- *
- * If the window is off the screen, then there is no image data in the
- * obscured/offscreen regions to be placed in the pixbuf. The contents of
- * portions of the pixbuf corresponding to the offscreen region are undefined.
- *
- * If the window you’re obtaining data from is partially obscured by
- * other windows, then the contents of the pixbuf areas corresponding
- * to the obscured regions are undefined.
- *
- * If the window is not mapped (typically because it’s iconified/minimized
- * or not on the current workspace), then %NULL will be returned.
- *
- * If memory can’t be allocated for the return value, %NULL will be returned
- * instead.
- *
- * (In short, there are several ways this function can fail, and if it fails
- * it returns %NULL; so check the return value.)
- *
- * Returns: (nullable) (transfer full): A newly-created pixbuf with a
- * reference count of 1, or %NULL on error
- */
-GdkPixbuf *
-gdk_pixbuf_get_from_window (GdkWindow *src,
- gint src_x,
- gint src_y,
- gint width,
- gint height)
-{
- cairo_surface_t *surface;
- cairo_surface_t *copy;
- cairo_t *cr;
- GdkPixbuf *dest;
- int scale;
-
- g_return_val_if_fail (GDK_IS_WINDOW (src), NULL);
- g_return_val_if_fail (gdk_window_is_viewable (src), NULL);
-
- surface = _gdk_window_ref_cairo_surface (src);
- scale = gdk_window_get_scale_factor (src);
-
- /* We do not know what happened to this surface outside of GDK.
- * Especially for foreign windows, they will have been modified
- * by external applications.
- * So be on the safe side and:
- */
- cairo_surface_mark_dirty (surface);
-
- if (cairo_surface_get_content (surface) & CAIRO_CONTENT_ALPHA)
- copy = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width * scale, height * scale);
- else
- copy = cairo_image_surface_create (CAIRO_FORMAT_RGB24, width * scale, height * scale);
-
- cairo_surface_set_device_scale (copy, scale, scale);
-
- cr = cairo_create (copy);
- cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
- cairo_set_source_surface (cr, surface, -src_x, -src_y);
- cairo_paint (cr);
- cairo_destroy (cr);
-
- dest = gdk_pixbuf_get_from_surface (copy, 0, 0, width * scale, height * scale);
-
- cairo_surface_destroy (copy);
- cairo_surface_destroy (surface);
-
- return dest;
-}
-
static cairo_format_t
gdk_cairo_format_for_content (cairo_content_t content)
{
*
* Transfers image data from a #cairo_surface_t and converts it to an RGB(A)
* representation inside a #GdkPixbuf. This allows you to efficiently read
- * individual pixels from cairo surfaces. For #GdkWindows, use
- * gdk_pixbuf_get_from_window() instead.
+ * individual pixels from cairo surfaces.
*
* This function will create an RGB pixbuf with 8 bits per channel.
* The pixbuf will contain an alpha channel if the @surface contains one.
}
}
-#if 0
-/**
- * gdk_cairo_create:
- * @window: a #GdkWindow
- *
- * Creates a Cairo context for drawing to @window.
- *
- * Note that calling cairo_reset_clip() on the resulting #cairo_t will
- * produce undefined results, so avoid it at all costs.
- *
- * Typically, this function is used to draw on a #GdkWindow out of the paint
- * cycle of the toolkit; this should be avoided, as it breaks various assumptions
- * and optimizations.
- *
- * If you are drawing on a native #GdkWindow in response to a %GDK_EXPOSE event
- * you should use gdk_window_begin_draw_frame() and gdk_drawing_context_get_cairo_context()
- * instead. GTK will automatically do this for you when drawing a widget.
- *
- * Returns: A newly created Cairo context. Free with
- * cairo_destroy() when you are done drawing.
- *
- * Since: 2.8
- *
- * Deprecated: 3.22: Use gdk_window_begin_draw_frame() and
- * gdk_drawing_context_get_cairo_context() instead
- **/
-cairo_t *
-gdk_cairo_create (GdkWindow *window)
-{
- cairo_region_t *region;
- cairo_surface_t *surface;
- cairo_t *cr;
-
- g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
-
- surface = _gdk_window_ref_cairo_surface (window);
-
- cr = cairo_create (surface);
-
- region = gdk_window_get_current_paint_region (window);
- gdk_cairo_region (cr, region);
- cairo_region_destroy (region);
- cairo_clip (cr);
-
- /* Assign a drawing context, if one is set; if gdk_cairo_create()
- * is called outside of a frame drawing then this is going to be
- * NULL.
- */
- gdk_cairo_set_drawing_context (cr, window->drawing_context);
-
- cairo_surface_destroy (surface);
-
- return cr;
-}
-#endif
-
/* Code for dirty-region queueing
*/
static GSList *update_windows = NULL;